<?php

namespace App\Models;

class Housings extends Model
{
    protected $fillable = [
        'field_name',
    ];
    protected $table = 'housings';
    protected $RentalType =[1=>'整间',2=>'单间'];
    protected $SourceHouse=[1=>'自有',2=>'租聘'];
    protected $NetworkType=[1=>'美团',2=>'飞猪',3=>'途家',4=>'携程',5=>'木鸟',6=>'其他'];
    protected $CommonUserType=[1=>'同一人',2=>'不是'];
    protected $RegisterType=[1=>'正常',2=>'注销'];
    protected $Type=[1=>'审核通过',2=>'申报中', 3=>'申报驳回', 4=>'申报失败'];

    protected $AddressType=[1=>'正常',2=>'修改中'];

    protected $IsRent=[1=>'是',2=>'否'];
    protected $OpenType=[1=>'个人',2=>'企业'];
    public function getOpenTypeAttribute($value)
    {
        return isset($this->OpenType[$value]) ? $this->OpenType[$value] : reset($this->OpenType);
    }

    public function getIsRentAttribute($value)
    {
        return isset($this->IsRent[$value]) ? $this->IsRent[$value] : reset($this->IsRent);
    }
    public function getRentalTypeAttribute($value)
    {
        return isset($this->RentalType[$value]) ? $this->RentalType[$value] : reset($this->RentalType);
    }
    public function getSourceHouseAttribute($value)
    {
        return isset($this->SourceHouse[$value]) ? $this->SourceHouse[$value] : reset($this->SourceHouse);
    }
    public function getNetworkTypeAttribute($value)
    {
        return isset($this->NetworkType[$value]) ? $this->NetworkType[$value] : reset($this->NetworkType);
    }
    public function getCommonUserTypeAttribute($value)
    {
        return isset($this->CommonUserType[$value]) ? $this->CommonUserType[$value] : reset($this->CommonUserType);
    }
    public function getTypeAttribute($value)
    {
        return isset($this->Type[$value]) ? $this->Type[$value] : reset($this->Type);
    }
    public function getRegisterTypeAttribute($value)
    {
        return isset($this->RegisterType[$value]) ? $this->RegisterType[$value] : reset($this->RegisterType);
    }

    public function getAddressTypeAttribute($value)
    {
        return isset($this->AddressType[$value]) ? $this->AddressType[$value] : reset($this->AddressType);
    }
    public function department()
    {
        return $this->hasOne(Department::class,'id','department_id');
    }

}
